<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Bootstrap core CSS -->
<link href="/admin/public/bootstrap.min.css" title="" rel="stylesheet" />
<link rel="stylesheet" href="/admin/css/plugins/toastr/toastr.min.css" />
<link href="/admin/font-awesome/css/font-awesome.min.css"
	rel="stylesheet">
<!-- 时间控件样式 -->
<link
	href="/admin/css/plugins/datetimepicker/bootstrap-datetimepicker.min.css"
	rel="stylesheet" media="screen">
<link href="/admin/public/animate.css" rel="stylesheet">
<link rel="stylesheet" href="/admin/public/inspinia.css" />
<link rel="stylesheet" href="/admin/css/templet_form.css" />
<!-- 图片放大缩小 -->
<link href="/admin/css/YLlightbox.css" rel="stylesheet" type="text/css">
<!-- Data Tables -->
<link href="/admin/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
<link href="/admin/css/plugins/dataTables/dataTables.responsive.css" rel="stylesheet">
<link href="/admin/css/plugins/dataTables/dataTables.tableTools.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css"
	href="${request.getContext }/admin/css/xcConfirm.css" />
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
	<script src="/admin/public/html5shiv.min.js"></script>
	<script src="/admin/public/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" href="/admin/css/Tab_swiper.css" />
<title>会员排名</title>
<style type="text/css">
th.prev {
	background: url(/admin/img/dateleft.png) -3px !important;
}

th.next {
	background: url(/admin/img/dateright.png) -10px !important;
}
</style>
</head>

<body>
	<div id="wrapper" class="container">
		<!--标编辑-->
		<div id="biaobj" class=" wrapper wrapper-content animated fadeInRight">
			<h3>会员排名</h3>
				<div class="right_box" id="right_box">
						<form action="/admin/ranking/selectAllInfo" class="form-horizontal">
					<div class="form-group">
						<div class="col-lg-3 col-md-3 col-sm-3" style="width: 270px;">
							<label for="" class="control-label" style="width:80px;float:left;margin-left: 10px">微信昵称:</label>
							<div class="col-lg-7 col-md-7 col-sm-7">
							<div  style="width:150px;float:left;">
								<input style="margin-left: -23px;" type="text" name="userName"
									id="userName" value="${userName }" class="form-control" />
									</div>
							</div>
						</div>
						<div class="col-lg-3 col-md-3 col-sm-3" style="width: 320px;">
							<label for="" class="control-label" style="width:80px;float:left;margin-left: 10px">排名条件:</label>
							<div class="col-lg-7 col-md-7 col-sm-7">
							<div  style="width:200px;float:left;">
								<select style="margin-left: -23px;" id="selectRankingIf" name="selectRankingIf" class=" select2_demo_1 form-control">
									<option value="1" <c:if test="${selectRankingIf eq 1 }">selected="selected"</c:if>>训练次数排名</option>
									<option value="2" <c:if test="${selectRankingIf eq 2 }">selected="selected"</c:if>>消费金额排名</option>
								</select>
								</div>
							</div>
						</div>
						<!-- 月份 -->
						<div class="col-lg-3 col-md-3 col-sm-3" style="width:250px;">
							<label for="" class="control-label" style="width:80px;float:left;margin-left: 10px">月份:</label>
							<div class="col-lg-7 col-md-7 col-sm-7">
								<div class="date input-append form_date ymd_date"
										id="addtimeCalendar" style="float: left; margin-right: 5px;">
										<div class="input-group">
										<div  style="width:150px;float:left;">
											<input class="form-control input-sm" type="text" style="width: 150px;"
												name="df" id="df" value="${df}" ><span
												class="add-on input-group-addon" style="position: relative; left: -150px;"> <i
												class="fa fa-calendar" style="color: black;"></i>
											</span>
											</div>
										</div>
									</div>
							</div>
						</div>
						<button style="width: 82px; height: 34px;" type="submit" id="search"
							class="col-lg-3 btn btn-success">搜索</button>
						<c:if test="${isc=='NO' }">
								<button onclick="pushJF('${df}')"
									style="width: 108px; height: 34px; margin-left: 15px;" disabled="disabled"
									type="button"  class="col-lg-3 btn btn-success">批量推送积分</button>
						</c:if>
						<c:if test="${isc=='YES' }">
									<button onclick="pushJF('${df}')"
										style="width: 108px; height: 34px; margin-left: 15px;" 
										type="button"  class="col-lg-3 btn btn-success">批量推送积分</button>
						</c:if>
					</div>
				</form>
						<!--上部表格部分-->
						<div class="ibox-content">
							<div class="row">
								<div class="col-sm-12">
									<table
										class="table table-striped table-bordered table-hover dataTables-example editable">
										<thead>
											<tr>
												<th style="display: none"></th>
												<th style="font-size: 12px;">微信昵称</th>
												<th style="font-size: 12px;">会员姓名</th>
												<th style="font-size: 12px;">会员手机号</th>
												<c:if test="${selectRankingIf eq 2 }"><th style="font-size: 12px;">消费排名</th></c:if>
												<c:if test="${selectRankingIf eq 2 }"><th style="font-size: 12px;">消费金额</th></c:if>
												<c:if test="${selectRankingIf eq 1 }"><th style="font-size: 12px;">训练次数排名</th></c:if>
												<c:if test="${selectRankingIf eq 1 }"><th style="font-size: 12px;">训练次数</th></c:if>
												<c:if test="${selectRankingIf eq 1 }">
												<th style="font-size: 12px;">消息推送(训练次数排名前${jifen.mingci }名)</th>
												</c:if>
											</tr>
										</thead>
										<tbody >
											<c:forEach items="${finlist }" var="a" varStatus="n">
												<tr>
													<td  style="display: none"></td>
													<td>${a.userName }</td>
													<td>${a.realname }</td>
													<td>${a.telenumber }</td>
													<c:if test="${selectRankingIf eq 2 }"><td><fmt:formatNumber value="${a.ranking }" /></td></c:if>
													<c:if test="${selectRankingIf eq 2 }"><td>${a.rechareMoney }<c:if test="${empty(a.rechareMoney ) }">0</c:if>元</td></c:if>
													<c:if test="${selectRankingIf eq 1 }"><td><fmt:formatNumber value="${a.ranking }" /></td></c:if>
													<c:if test="${selectRankingIf eq 1 }"><td>${a.exerciseTime }<c:if test="${empty(a.exerciseTime ) }">0</c:if>次</td></c:if>
													<c:if test="${selectRankingIf eq 1 }">
													<td>
														<c:if test="${a.ranking le jifen.mingci }">
															<c:forEach items="${fenshuList }" var="test" varStatus="nn">
																<c:if test="${test.index eq  a.ranking}"><a >(奖励${test.fen }分)</c:if></a>
															</c:forEach>
														</c:if>
													</td>
													</c:if>
												</tr>
											</c:forEach>
										</tbody>
									</table>
								</div>
							</div>
							<div class="row">
						<form action="/admin/shop/list" id="for" name="for" method="post">
							<input type="hidden" name="yehao" id="yin" value="1"> <input
								type="hidden" name="pagesize" id="tiaoshu"
								value="${page.pageSize }">
							<div class="fy">
								<span style="float: left;font-size: 12px;">每页条数：</span> <select
									style="width: 70px; float: left;font-size: 12px;"
									onchange="changeItem(this.value)" id="pagesize" name="pageSize">
									<option value="10" ${page.pageSize==10?'selected':'' }>10</option>
									<option value="20" ${page.pageSize==20?'selected':'' }>20</option>
									<option value="50" ${page.pageSize==50?'selected':'' }>50</option>
									<option value="100" ${page.pageSize==100?'selected':'' }>100</option>
									<option value="200" ${page.pageSize==200?'selected':'' }>200</option>
								</select>
								<div style="height: 27px;" class="col-sm-7">
									<div class="dataTables_paginate paging_simple_numbers"
										id="editable_paginate">
										<ul class="pagination pull-right" style="margin: -3px 0;">
											<li class="paginate_button previous" id="editable_previous">
												<a href="javascript:han(${page.pageNow-1 })"
												aria-controls="editable" data-dt-idx="0" tabindex="0" style="font-size: 12px;">上一页</a>
											</li>
											<li class="paginate_button previous" id="editable_previous">
												<a aria-controls="editable" style="border: 0;font-size: 12px;"
												data-dt-idx="0" tabindex="1"><input type="text"
													id="current"
													style="width: 32px; height: 19px; text-align: center;font-size: 12px;"
													value="${page.totalPageCount==0?0:page.pageNow}" /> /
													${page.totalPageCount }</a>
											</li>
											<li class="paginate_button previous" id="editable_previous" style="font-size: 12px;">
												<a href="javascript:han(${page.pageNow+1 })"
												aria-controls="editable" data-dt-idx="0" tabindex="5" style="font-size: 12px;">下一页</a>
												<a href="javascript:han($('#current').val())"
												aria-controls="editable" data-dt-idx="0" tabindex="5" style="font-size: 12px;">跳转</a>
											</li>
										</ul>
									</div>
								</div>
								<div style="float: right;font-size:12px;">总共${page.totalCount }条</div>
							</div>

						</form> 
					</div>
						</div>
						
				</div>
		</div>
	</div>
	<script src="/admin/public/jquery-1.11.3.js"></script>
	<script src="/admin/public/bootstrap.min.js" type="text/javascript"></script>
	<script src="/admin/js/plugins/lhgdialog/lhgdialog.js"></script>
	<!-- 弹出警示框 -->
	<script src="/admin/js/plugins/toastr/toastr.min.js"></script>
	<!-- 弹出确认框 -->
	<script src="/admin/public/artDialog4.1.7/artDialog.js?skin=blue"></script>
	<script src="/admin/public/artDialog4.1.7/plugins/iframeTools.js"></script>
	<!-- 时间控件样式 -->
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker.min.js"></script>
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker-update.min.js"></script>
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
	<!-- Data Tables -->
	<script src="/admin/js/plugins/dataTables/jquery.dataTables.js"></script>
	<script src="/admin/js/plugins/dataTables/dataTables.bootstrap.js"></script>
	<script src="/admin/js/plugins/dataTables/dataTables.responsive.js"></script>
	<script src="/admin/js/plugins/dataTables/dataTables.tableTools.min.js"></script>
	
	<script src="/admin/js/templet_form.js"></script>
	<script type="text/javascript"
		src="http://api.map.baidu.com/api?v=2.0&ak=67jMQ5DmYTe1TLMBKFUTcZAR"></script>
	<script src="/admin/js/Tab_swiper.js"></script>
	<script src="${request.getContext }/admin/js/xcConfirm.js"
		type="text/javascript" charset="utf-8"></script>
	
	<!-- 表格排序 -->
	<script type="text/javascript">
	$(".ymd_date").datetimepicker({　
		format: 'yyyy-mm',
		autoclose: true,
		todayBtn: true,
		startView: 'year',
		minView: 'year',
		maxView: 'decade',
		language: 'zh-CN',
		pickerPosition: "bottom-left"
	});
		//处理也见面加载弹出的错误信息
		$.fn.dataTable.ext.errMode = 'none'; //不显示任何错误信息
		//dataTable的初始化	
		$(document).ready(function() {
			/* Init DataTables */
			//var oTable = $('#editable').DataTable();
			//定义每页显示数据数量
			/* $('.editable').dataTable( {  
				"aLengthMenu": [[10, 25, 50, -1], [5, 10, 20, 50]],
				language: {
			        "sProcessing": "处理中...",
			        "sLengthMenu": "显示 _MENU_ 项结果",
			        "sZeroRecords": "没有匹配结果",
			        "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
			        "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
			        "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
			        "sInfoPostFix": "",
			        "sSearch": "搜索:",
			        "sUrl": "",
			        "sEmptyTable": "表中数据为空",
			        "sLoadingRecords": "载入中...",
			        "sInfoThousands": ",",
			        "oPaginate": {
			            "sFirst": "首页",
			            "sPrevious": "上页",
			            "sNext": "下页",
			            "sLast": "末页"
			        },
			        "oAria": {
			            "sSortAscending": ": 以升序排列此列",
			            "sSortDescending": ": 以降序排列此列"
			        }
			    }
			}); */
			$('.editable').dataTable({
				"bPaginate": false, //翻页功能
				"bLengthChange": false, //改变每页显示数据数量
				"bFilter": false, //过滤功能
				"bSort": true, //排序功能
				"bInfo": false,//页脚信息
				"bAutoWidth": false,//自动宽度
				language: {
					"sEmptyTable": "暂无数据"
				}
				
			});
			
		});
		//增加一行的功能
		/* function fnClickAddRow() {
			$('#editable').dataTable().fnAddData([
				"Custom row",
				"New row",
				"New row",
				"New row",
				"New row"
			]);

		} */
	</script>
	<script type="text/javascript">
	//分页
	function han(pn){
		document.getElementById("yin").value=pn;
		var biao=document.getElementById("for");
		document.for.action="/admin/ranking/selectAllInfo?userName="+document.all.userName.value+"&selectRankingIf="+document.all.selectRankingIf.value+"&df="+document.all.df.value;
		biao.submit();
	}
	function changeItem(size) {
		document.getElementById("tiaoshu").value=size;
		var biao=document.getElementById("for");
		document.for.action="/admin/ranking/selectAllInfo?userName="+document.all.userName.value+"&selectRankingIf="+document.all.selectRankingIf.value+"&df="+document.all.df.value;
		biao.submit();
	}
	//推送
	function tuisong(userId,fen){
		window.wxc.xcConfirm("确定要奖励积分吗？", window.wxc.xcConfirm.typeEnum.confirm,{onOk:function(){ 
  			$.post("/admin/ranking/tuisong",{"userId":userId,"fen":fen},
  			function(data){
  				window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.info,
						{onOk:function(){window.location.href="/admin/ranking/selectAllInfo";}}
				)
  			});
  		}})
	}
	//批量推送积分
	function pushJF(df){
		window.wxc.xcConfirm("每月只有一次奖励机会，确定要奖励积分吗？", window.wxc.xcConfirm.typeEnum.confirm,{onOk:function(){ 
  			$.post("/admin/ranking/pltuisong?df="+df,
  			function(data){
  				window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.info,
						{onOk:function(){$("#search").click();}}
				)
  			});
  		}})
	}
	</script>
</body>
</html>